#include<bits/stdc++.h>
using namespace std;
int ABS(int n){
    if(n<=0) return -n;
    else return n;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        int n,m;
        int l,v1;
        cin>>n>>m>>l>>v1;
/*
        if(n<=20&&m<=20){
            double d[1005],v[1005],a[1005],q[1005];
            for(int i=0;i<n;i++){
                cin>>d[i]>>v[i]>>a[i];
            }
            for(int i=0;i<m;i++){
                cin>>q[i];
            }
            int s1=0,s2=0;
            for(int i=0;i<n;i++){
                if(v[i]<=v1&&a[i]<=0){continue;}
                double t=(v1*v1-v[i]*v[i])/2/a[i];
                t+=d[i];
                if(a[i]==0)t=d[i];
                if(a[i]>=0){
                    for(int j=m-1;j>=0;j--){
                        if(d[i]>q[j])break;
                        if(t<q[j]){
                            s1++;
                            break;
                        }
                    }
                }
                else{
                    for(int j=0;j<m;j++){
                        if(t>q[j]&&d[i]<=q[j]){
                            s1++;
                            break;
                        }
                    }
                }
            }
            cout<<s1;
        }
*/
        int d[100005],v[100005],a[100005],q[100005];
        for(int i=0;i<n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
         for(int i=0;i<m;i++){
            cin>>q[i];
        }
        int s1=0,s2=0;
        for(int i=0;i<n;i++){
            if(v[i]>v1&&d[i]<=q[m-1])s1++;
        }
        if(s1!=0)s2=m-1;
        else s2=m;
        cout<<s1<<" "<<s2<<endl;
    }
    return 0;
}
